package it.fuesi.expired.formbinders;

import android.app.Activity;
import android.content.Intent;
import android.widget.EditText;

import it.fuesi.expired.R;
import it.fuesi.expired.adapters.AbstractAdapter;
import it.fuesi.expired.api.client.TagsBroker;
import it.fuesi.expired.model.Tag;
import it.fuesi.expired.model.base.AModel;

/**
 * Created by pascotto on 22/08/14.
 */
public class TagFormBinder extends AbstractFormBinder<Tag> {


    private EditText mName;


    @Override
    protected TagsBroker getClientBroker() {
        return new TagsBroker(AbstractAdapter.API_ENDPOINT);
    }

    @Override
    public AModel makeObject(Activity activity) {

        final EditText mName = (EditText)activity.findViewById(R.id.name);
        final String name = mName.getText().toString();

        final Tag t = new Tag();
        t.setName(name);
        return t;
    }

    @Override
    public void bindObject(Activity activity, Tag obj) {
        mName.setText(obj.getName());

    }

    @Override
    public void onCreate(final Activity activity){
        mName = (EditText)activity.findViewById(R.id.name);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    }
}
